# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
from cerbero.utils import shell


class Recipe(recipe.Recipe):
    name = 'libogg'
    version = '1.3.3'
    stype = SourceType.TARBALL
    url = 'xiph://ogg/%(name)s-%(version)s.tar.xz'
    tarball_checksum = '4f3fc6178a533d392064f14776b23c397ed4b9f48f5de297aba73b643f955c08'
    licenses = [{License.BSD_like: ['COPYING']}]
    autoreconf = True
    patches = ['libogg/0001-Fix-iOS-build.patch']

    files_libs = ['libogg']
    files_devel = ['include/ogg', 'lib/pkgconfig/ogg.pc', 'share/aclocal/ogg.m4']

    async def configure(self):
        if self.config.target_platform == Platform.IOS:
            if Architecture.is_arm(self.config.target_arch):
                # These optimizations make the linker think the object file is not
                # for the arm architecture
                shell.replace (os.path.join(self.build_dir, 'configure.ac'),
                               {'-O4': '-O2'})
        await super(recipe.Recipe, self).configure()
